package com.tps.vunes.admin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tps.vunes.admin.dao.SystemUserMapper;
import com.tps.vunes.admin.model.SystemUser;
import com.tps.vunes.admin.service.SystemUserService;

@Service
public class SystemUserServiceImpl implements SystemUserService{

	@Autowired
	private SystemUserMapper systemUserMapper;
	
	@Override
	public SystemUser selectById(Integer userId) {
	
		return systemUserMapper.selectById(userId);
	}

	@Override
	public int deleteByIds(Integer[] userId) {
		if(null ==userId || userId.length<=0) {
			return -1;
		}
		return systemUserMapper.deleteByIds(userId);
	}

	@Override
	public int insertUser(SystemUser record) {
		if(null == record) {
			return -1;
		}
		return systemUserMapper.insertUser(record);
	}

	@Override
	public SystemUser selectLogin(String loginName, String password) {
		
		return systemUserMapper.selectLogin(loginName, password);
	}

	@Override
	public PageInfo<SystemUser> selectUserList(SystemUser user) {
		PageHelper.startPage(user.getPageNum(), user.getPageSize());
		PageInfo<SystemUser> pageInfo =new PageInfo<>();
		List<SystemUser> list=systemUserMapper.selectUserList(user);
		pageInfo.setList(list);
		return pageInfo;
	}

	@Override
	public int updateById(SystemUser record) {
		return systemUserMapper.updateById(record);
	}

}
